﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Wormhole.Engine.Communication.Messages
{
	/// <author>Hannes Foulds</author>
	/// <date>05 September 2008</date>
	/// <summary>
	/// This class handles random seed messages.
	/// </summary>
	public class RandomSeedMessage : Message
	{
		#region Properties

		#region Random Seed
		/// <summary>
		/// The random seed value.
		/// </summary>
		public int Seed { get; set; }
		#endregion

		#endregion

		#region Constructor
		/// <summary>
		/// Initialize a default instance of the class.
		/// </summary>
		public RandomSeedMessage()
		{
		}

		/// <summary>
		/// Initialize the class with the values provided.
		/// </summary>
		/// <param name="message">The string message to parse.</param>
		public RandomSeedMessage(string message) : this()
		{
			this.Parse(message);
		}
		#endregion

		#region Parse
		/// <summary>
		/// Parse the string message that was received.
		/// </summary>
		/// <param name="message">The message.</param>
		private void Parse(string message)
		{
			string[] messageParts = message.Split('|');
			this.Seed = Convert.ToInt32(messageParts[1]);
		}
		#endregion

		#region To String
		/// <summary>
		/// Convert the message to a string that can be send via the communications channel.
		/// </summary>
		/// <returns>Returns the string representation of the message.</returns>
		public override string ToString()
		{
			return string.Format("{0}|{1}", EnumConvertor<Actions>.ToString(Actions.RandomSeed), this.Seed); 
		}
		#endregion
	}
}
